<%@page import="connection.*, java.sql.*" %>
<%
//get number of unread messages
//SELECT COUNT(*) FROM Message WHERE Receiver = '[username]' AND Unread = 1
String sql = "SELECT COUNT(Message.Unread) FROM Message, User_Msg WHERE User_Msg.MsgID = Message.MessageID AND User_Msg.Username = '"+(String)session.getAttribute("username")+"' AND Message.Unread = 1";
String hasmail = "";
System.out.println(sql);
try{
	DbConnection db = new DbConnection();
	ResultSet rs = db.getConn().prepareStatement(sql).executeQuery();
	while(rs.next()){
		hasmail = rs.getString(1);
		
	}db.close();
}catch(SQLException e){
	System.out.println(e.toString());
}

System.out.println("hasmail:"+hasmail);
%>

<div class="title"><img src="/DBP/images/title2.png"></div>

<div class="nav"> 
		<div class="navelement">
			<a href="/DBP/success.jsp"><img src="/DBP/images/home.png" /></a>
		</div>
		<div class="navelement">
		
			<a href="/DBP/messages.jsp"><img src="/DBP/images/messages.png" /></a>
			<span style="color:#<%if(hasmail.equals("0")){ %>383<%}else{%>3d3<%} %>;font-size:12pt;top:93px;left:71px;position:absolute;"><%=hasmail %></span>
		</div>
		<div class="navelement">
			<a href="/DBP/settings.jsp"><img src="/DBP/images/settings.png" /></a>
		</div>
		<div class="navelement">
			<a href="/DBP/OnlineHelp/Help.jsp"><img src="/DBP/images/faq.png" /></a>
		</div>
		
		
		<div class="navelement" id="logout">
			<a href="/DBP/login.jsp?logout=true"><img src="/DBP/images/logout.png" /></a>
		</div>
		<div style="width:auto; " id="info">You are logged in as: <%=(String)session.getAttribute("username")%><br/>Access level:<%if(session.getAttribute("accessibility") != null){%>
		<%
		String access;
		String a = session.getAttribute("accessibility").toString();
		switch(Integer.parseInt(a)){
			case 1:
				access = "Poll user";
				break;
			case 2:
				access = "Poll Master";
				break;
			case 3:
				access ="Poll Creator";
				break;
			case 4:
				access ="Poll Admin";
				break;
			case 5:
				access ="System Admin";
				break;
			default:
				access = "bleagh";
		}
		out.write(access);%><%}else{out.println("whaaat");} %></div>
</div>